package smartcase.config.auth;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import smartcase.base.auth.AuthenticationInterceptor;

@Configuration
public class AuthCheckConfigurationAdapter implements WebMvcConfigurer {

  private final AuthenticationInterceptor authenticationInterceptor;

  public AuthCheckConfigurationAdapter(AuthenticationInterceptor authenticationInterceptor) {
    this.authenticationInterceptor = authenticationInterceptor;
  }

  @Override
  public void addInterceptors(InterceptorRegistry registry) {
    registry
        .addInterceptor(authenticationInterceptor)
        .addPathPatterns("/**")
        .order(1);
  }
}
